﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.controllers.windows.sun {
    import net.wooga.pets.views.windows.*;
    import net.wooga.pets.events.windows.*;
    import net.wooga.pets.controllers.windows.*;

    public class BuildSunWindowCommand extends WindowCommand {

        override public function execute():void{
            if (windowsModel.existsWindowWithSameKey(windowBuildOptions.textValues.body)){
                return;
            };
            var _local1:IWindowView = buildViewFromVo(windowBuildOptions);
            windowsModel.appendNewWindowToQue(_local1);
            if (windowsModel.hasNoCurrentViewSet){
                this.sendViewToMediator();
            } else {
                if (windowsModel.viewIsSetToAutoClose(windowsModel.currentView) == false){
                    this.removeCurrentView();
                };
            };
        }
        private function sendViewToMediator():void{
            this.eventDispatcher.dispatchEvent(new WindowsMainViewUpdateEvent(WindowsMainViewUpdateEvent.ADD_SUN_WINDOW, windowsModel.nextWindow));
        }
        private function removeCurrentView():void{
            var _local1:WindowCommandTriggerEvent = new WindowCommandTriggerEvent(WindowCommandTriggerEvent.DESTROY_SUN_WINDOW);
            _local1.window = windowsModel.currentView;
            dispatch(_local1);
        }

    }
}//package net.wooga.pets.controllers.windows.sun 
